<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../forms/resources/picker-common.js"></script>
<script src="resources/calendar-picker-common.js"></script>
</head>
<body>

<input type=date id=date value="2019-05-01">

<script>
let t = async_test('Test Japanase imperial era names');

function test1() {
  let pw = popupWindow;
  const NEN = '\u5e74';
  const GANNEN = '\u5143\u5e74';
  const REIWA = '\u4ee4\u548c';
  const HEISEI = '\u5e73\u6210';
  const SYOUWA = '\u662d\u548c';
  const TAISYOU = '\u5927\u6b63';
  const MEIJI = '\u660e\u6cbb';
  const JAN = 0, APR = 3, MAY = 4, JUL = 6, AUG = 7, SEP = 8, OCT = 9, NOV = 10, DEC = 11;
  assert_equals(pw.formatJapaneseImperialEra(275760, SEP), '');
  assert_equals(pw.formatJapaneseImperialEra(2118, JAN), '');
  assert_equals(pw.formatJapaneseImperialEra(2117, JAN), `(${REIWA}99${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(2020, JAN), `(${REIWA}2${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(2019, MAY), `(${REIWA}${GANNEN})`);
  assert_equals(pw.formatJapaneseImperialEra(2019, APR), `(${HEISEI}31${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1990, JAN), `(${HEISEI}2${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1989, JAN), `(${HEISEI}${GANNEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1988, JAN), `(${SYOUWA}63${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1927, JAN), `(${SYOUWA}2${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1926, DEC), `(${TAISYOU}15${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1913, JAN), `(${TAISYOU}2${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1912, AUG), `(${TAISYOU}${GANNEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1912, JUL), `(${MEIJI}45${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1869, JAN), `(${MEIJI}2${NEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1868, NOV), `(${MEIJI}${GANNEN})`);
  assert_equals(pw.formatJapaneseImperialEra(1868, OCT), '');
  assert_equals(pw.formatJapaneseImperialEra(1867, DEC), '');
  assert_equals(pw.formatJapaneseImperialEra(1, JAN), '');
}

t.step(() => {
  openPicker(document.getElementById('date'), t.step_func_done(test1));
});
</script>
</body>
</html>
